<template >
  <div>
    <div>关于你的考试记录♥</div>
    <div>
      <el-table :data="record" stripe border style="width: 100%" >

        <el-table-column prop="sid" label="学号" align="center" style="width:25%"></el-table-column>
        <!--        <el-table-column prop="name" label="姓名" align="center" style="width:25%"></el-table-column>-->
        <el-table-column prop="test_result" label="考试结果" align="center" style="width:33%"></el-table-column>
        <el-table-column prop="test_time" label="考试时间" align="center" style="width:33%"></el-table-column>
        <el-table-column label="删除" align="center" style="width:33%">
          <template #default="scope">
<!--            <el-button type="warning" @click="editRecord(scope.row)">编辑</el-button>-->
<!--            <el-divider direction="vertical" />-->
            <el-button type="danger" @click="deleteRecord(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div>
      <!--      编辑的dialog-->
<!--      <el-dialog v-model="this.dialogVisible" @close="this.dialogVisible = false" >-->
<!--        <el-form :model="this.editForm" :rules="rules" ref="editForm">-->
<!--&lt;!&ndash;          <el-form-item prop="s_id" label="s_id">&ndash;&gt;-->
<!--            <el-input placeholder="请输入id" v-model="this.editForm.sid"></el-input>-->
<!--          </el-form-item>-->
          <!--          <el-form-item prop="name" label="sname">-->
          <!--            <el-input placeholder="请输入name" v-model="this.editForm.name"></el-input>-->
          <!--          </el-form-item>-->
<!--          <el-form-item prop="test_result" label="test_result">-->
<!--            <el-input placeholder="请输入test_result" v-model="this.editForm.test_result"></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item prop="test_time" label="test_time">-->
<!--            <el-input placeholder="请输入test_time" v-model="this.editForm.test_time" disabled="true"></el-input>-->
<!--          </el-form-item>-->
<!--        是否确认删除？-->

<!--        </el-form>-->
<!--        <el-button-group>-->
<!--          <el-button type="primary" size="mini" @click="this.dialogVisible = false;">确认</el-button>-->
<!--          <el-button type="info" size="mini" @click="this.dialogVisible = false;">取消</el-button>-->
<!--        </el-button-group>-->
<!--      </el-dialog>-->
    </div>
  </div>
</template>

<script>
export default {
  name: "path3",

  // inject:['reload'],
  // return{refresh};


  data() {
    return {
      flag:true,
      record: [],
      dialogVisible : false,
      // editForm : {
      //   sid : '',
      //   // sname : '',
      //   test_time : '',
      //   test_result : '',
      // },
      // rules : {
      //   sid : [
      //     {required: true, message: '请输入学号', trigger: 'blur'}
      //   ],
      //   // sname : [
      //   //   {required: true, message: '请输入name', trigger: 'blur'}
      //   // ],
      //   test_time : [
      //     {required: true, message: '请输入测试时间', trigger: 'blur'}
      //   ],
      //   test_result : [
      //     {required: true, message: '请输入测试结果', trigger: 'blur'}
      //   ],
      // }
    }
  },
  created() {
    this.initRecord();
  },
  methods: {

    initRecord() {
      this.$axios.post("api/StuResult").then(res => {
        console.log("考试记录 = ", res.data);
        this.record = res.data.data;
      })
    },
    // editRecord(row) {
    //   this.dialogVisible = true;
    //   this.editForm.sid = row.sid
    //   // this.editForm.name = row.sname
    //   this.editForm.test_time = row.test_time
    //   this.editForm.test_result = row.test_result
    //
    // },
    // editRecordSubmit(row) {
    //
    //   let data = {
    //     sid :this.editForm.sid,
    //     test_time:this.editForm.test_time,
    //     test_result:this.editForm.test_result
    //   };
    //   this.$axios.post(`/EditResult`,data).then((res) =>{
    //     if(res.data.msg === "更新成功"){
    //       this.initRecord()
    //     }
    //     else{
    //
    //     }
    //   })
    //
    // },
    // resetForm(formName) {
    //   this.$refs[formName].resetFields();
    // },

    deleteRecord(row) {

        let data = {
          test_time:row.test_time
        }

        this.$axios.post(`api/StuDelResult`,data).then(res => {
          if(res.data === "删除成功"){
            this.initRecord()
          }
          else{

          }
        })

      }


    }



}
</script>

<style scoped>

</style>